#ifndef FREEFLYCAMERA_H
#define FREEFLYCAMERA_H

#include "../Config/Export.h"
#include "../Maths/TVector3.h"
#include "../Maths/TVector2.h"
#include <string>
#include <map>

namespace epix {

class SHARED FreeFlyCamera
{
    public:

        FreeFlyCamera(const Vector3d & position = Vector3d());
        FreeFlyCamera(double posX, double posY, double posZ);
        
        virtual ~FreeFlyCamera();

        virtual void resetCamera();

        virtual void setKeyMap(int forward, int backward, int left, int right, int boost);
        virtual void onEvent();

        virtual void animate();

        virtual void setSpeed(double speed);
        virtual void setSensivity(double sensivity);
        virtual void setPosition(const Vector3d & position);

        virtual const Vector3d &getPosition() const;
        virtual const Vector3d &getTarget() const;
        virtual const Vector3d &getForward() const;
        virtual const double &getTheta() const;
        virtual const double &getPhi() const;

        virtual void look();

    private:

        void VectorsFromAngles();

        double _speed, _sensivity;

        typedef std::map<std::string, bool> KeyStates;
        typedef std::map<std::string, int> KeyMap;
        KeyStates _keystates;
        KeyMap _keymap;

        Vector3d _position, _target, _forward, _left;

        double _theta, _phi;

        double _now, _start_time, _time_step;

};

}

#endif

